from django.db import models
from django.utils.html import format_html

from datetime import datetime


# Create your models here.


class GoodsCategoryBrand(models.Model):
    """
    品牌名
    """
    name = models.CharField(default='', max_length=30, verbose_name='品牌名', help_text='品牌名')
    image = models.ImageField(max_length=200, upload_to='brand/%Y/%m')
    add_time = models.DateTimeField(default=datetime.now, verbose_name='添加时间')

    def banner_imamge_url(self):
        print(self.image)
        return format_html('<img src="{0}" width="100px"/>', self.image.url)

    banner_imamge_url.short_description = u'图片'

    class Meta:
        verbose_name = '品牌名'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
